<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>路径</title>
		<style type="text/css">
			* {
				padding: 0;
				margin: 0;
			}
			
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			
			canvas {
				width: 500px;
				height: 500px;
				border: 2px solid blue;
			}
		</style>
	</head>

	<body>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>
	<script type="text/javascript">
		window.onload = function() {
			let oCanvas = document.getElementById('canvas');
			console.dir(oCanvas);
			let oPen = oCanvas.getContext("2d");
			
			/*oPen.lineWidth=10;
			oPen.strokeStyle="blue";
			oPen.moveTo(100,100);
			oPen.lineTo(200,100);
			oPen.stroke();
			
			oPen.beginPath();
			oPen.strokeStyle="red";
			oPen.moveTo(100,200);
			oPen.lineTo(200,200);
			oPen.stroke();*/
			
			/*oPen.arc(150,150,100,0,Math.PI/180*120,false);
			oPen.closePath();
			oPen.stroke();
			
			oPen.beginPath();
			oPen.arc(250,250,100,0,Math.PI/180*120,false);
			oPen.closePath();
			oPen.stroke();*/
			
			//这个点的坐标   如果这个点在路径中，就返回true,否则就返回false
			//isPointInPath(x,y);
			
			oPen.rect(50,50,80,80);
			oPen.stroke();
			oPen.fill();
			
			if (oPen.isPointInPath(60,60)) {
				alert('在路径中')
			} else{
				alert('不在路径中')
			}
			
		}
	</script>
	</body>

</html>